package com.tj.collection.controller.admin.request;


import com.fqgj.common.api.ParamsObject;
import com.tj.collection.db.domain.Menu;

/**
 * Created with IntelliJ IDEA.
 * User: sm
 * Date: 2016/11/17
 * Time: 下午3:41
 */
public class AddMenuVo extends ParamsObject {
    private Long firstMenu = 0L;
    private Long secondMenu = 0L;
    private String name = "";
    private String url = "";
    /**
     * 菜单类型 0-内部使用 1-商户通用
     */
    private Integer menuType = 0;

    public Long getFirstMenu() {
        return firstMenu;
    }

    public AddMenuVo setFirstMenu(Long firstMenu) {
        this.firstMenu = firstMenu;
        return this;
    }

    public Long getSecondMenu() {
        return secondMenu;
    }

    public AddMenuVo setSecondMenu(Long secondMenu) {
        this.secondMenu = secondMenu;
        return this;
    }

    public String getName() {
        return name;
    }

    public AddMenuVo setName(String name) {
        this.name = name;
        return this;
    }

    public String getUrl() {
        return url;
    }

    public AddMenuVo setUrl(String url) {
        this.url = url;
        return this;
    }

    public Integer getMenuType() {
        return menuType;
    }

    public AddMenuVo setMenuType(Integer menuType) {
        this.menuType = menuType;
        return this;
    }

    @Override
    public void validate() {

    }

    public Menu tran2Menu() {
        Long parentId = 0L;
        if (firstMenu == null || firstMenu == 0L) {
            parentId = 0L;
        } else {
            parentId = (secondMenu == null || secondMenu == 0L) ? firstMenu : secondMenu;
        }
        Menu menu = new Menu()
                .setParentId(parentId)
                .setKey(name)
                .setValue(url)
                .setMenuType(menuType);
        return menu;
    }
}
